package app.dis.negocio;

import java.util.List;

import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.Query;

import app.dis.modelo.Cliente;


@Stateless
public class ClienteDao {

	@Inject
	private EntityManager em;
	
	public void insert(Cliente c){
		em.persist(c);
	}
	
	public Cliente read(String id){
		Cliente m = em.find(Cliente.class, id);
		return m;
	}
public List<Cliente> getCliente(String  id){
		
		String sql = "SELECT c From Cliente c WHERE c.per_cedula = :per_cedula";
		
		Query q =  em.createQuery(sql, Cliente.class);
		q.setParameter("per_cedula", id);
		
		List<Cliente> lst = q.getResultList();
		
		return lst;
	}
}